﻿using System;
using System.IO;

namespace AGMRestAPITest
{
    public class Helper
    {
        private static readonly Random Rng = new Random();
        private const string Chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

        public static string RandomString(int size)
        {
            var buffer = new char[size];

            for (var i = 0; i < size; i++)
            {
                buffer[i] = Chars[Rng.Next(Chars.Length)];
            }
            return new string(buffer);
        }

        public static bool CheckAttachment(string filepath)
        {
            if (!File.Exists(filepath))
                return false;

            using (var sr = new StreamReader(filepath))
            {
                var content = sr.ReadToEnd();
                return content.Equals("Attachment.");
            }
        }
    }
}
